package com.zackeus.xupdate.constant;

import androidx.annotation.IntDef;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 异常标识
 * @name: ERROR
 * @author: zz
 * @date: 2022/11/18
 */
public final class Error {

    /* 网络请求错误 */
    public static final int CHECK_NET_REQUEST = 2000;
    /* 无wifi */
    public static final int CHECK_NO_WIFI = CHECK_NET_REQUEST + 1;
    /* 无网络 */
    public static final int CHECK_NO_NETWORK = CHECK_NO_WIFI + 1;
    /* 正在更新 */
    public static final int CHECK_UPDATING = CHECK_NO_NETWORK + 1;
    /* 已是最新版本 */
    public static final int CHECK_NO_NEW_VERSION = CHECK_UPDATING + 1;
    /* json 为空 */
    public static final int CHECK_JSON_EMPTY = CHECK_NO_NEW_VERSION + 1;
    /* 解析失败 */
    public static final int CHECK_PARSE = CHECK_JSON_EMPTY + 1;
    /* 被忽略的版本 */
    public static final int CHECK_IGNORED_VERSION = CHECK_PARSE + 1;
    /* 目录为空 */
    public static final int CHECK_APK_CACHE_DIR_EMPTY = CHECK_IGNORED_VERSION + 1;

    /* 未知错误 */
    public static final int PROMPT_UNKNOWN = 3000;
    /* ACTIVITY 已销毁 */
    public static final int PROMPT_ACTIVITY_DESTROY = PROMPT_UNKNOWN + 1;

    /* 下载失败 */
    public static final int DOWNLOAD_FAILED = 4000;
    /* 权限被拒绝 */
    public static final int DOWNLOAD_PERMISSION_DENIED = DOWNLOAD_FAILED + 1;

    /* 安装失败 */
    public static final int INSTALL_FAILED = 5000;

    /* 未知错误 */
    public static final int UPDATE_UNKNOWN = 5100;

    @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({CHECK_NET_REQUEST, CHECK_NO_WIFI, CHECK_NO_NETWORK, CHECK_UPDATING, CHECK_NO_NEW_VERSION,
            CHECK_JSON_EMPTY, CHECK_PARSE, CHECK_IGNORED_VERSION, CHECK_APK_CACHE_DIR_EMPTY,
            PROMPT_UNKNOWN, PROMPT_ACTIVITY_DESTROY, DOWNLOAD_FAILED, DOWNLOAD_PERMISSION_DENIED,
            INSTALL_FAILED, UPDATE_UNKNOWN})
    public @interface Unit {}
}
